<template>
  <DataList :name="name" :cate="cate" :single="true" :cols="cols" />
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import { addGzts, deleteGzts, updateGzts, getGzts } from "@/api/馆藏图书资料.js";
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A3-2馆藏图书资料",
      name:'3.2 馆藏图书资料',
      cols: [
        { label: "纸质图书(万册)", prop: "馆藏图书资料_纸质图书",
        data:[
          { label: "总册数", prop: "TS"},
          { label: "本学年新增数", prop: "BXNZZTSXZS"},
        ] },
        { label: "专业期刊(种)", prop: "馆藏图书资料_专业期刊",
        data:[
          { label: "中文纸质专业期刊", prop: "ZWZZZYQK"},
          { label: "外文纸质专业期刊", prop: "WWZZZYQK"},
          { label: "电子专业期刊", prop: "DZZYQK"},
        ] },
        
      ]
    };
  },
  methods: {
  
    async fetchData() {
      var user = getUser();
      var datas = await getGzts(user.XXID,user.CJPC);
      return datas;
    },
    onadd(model){
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
      
          console.log(JSON.stringify(temp));
          var model = await addGzts(temp);
          resolve(model);
      })
    },
    
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateGzts(temp);
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deleteGzts(temp);
          resolve();
      })
    }
  }
};
</script>
<style>
</style>